﻿using System;
using System.Configuration;
using System.ServiceModel;
using AutomationTestCases;
using AutomationTestCases.AutomationTestCommon;
using MonitorServer;

namespace radius_netTest
{
    class Program
    {
        private const int sleepTime = 1000;

        private static string userName = ConfigurationManager.AppSettings["UserName"];
        private static string password = ConfigurationManager.AppSettings["Password"];
        private static string repository = ConfigurationManager.AppSettings["Repository"];
        private static string location = ConfigurationManager.AppSettings["Location"];
        //private static ChannelFactory<IMessageQueue> channelFactory = new ChannelFactory<IMessageQueue>("MessageQueueService");
        static void Main(string[] args)
        {
            //TestDsmStore();
            TestIntranet();
        }

        private static void TestIntranet()
        {
            //IMessageQueue service = channelFactory.CreateChannel();
            var browser = new AutomationTestBase();

            //// Scenario one
            //var ScenarioAction = new MonitorServer.Action() { Scenario = 1, BeginTime = DateTime.Now, Location = location };
            //browser.GoToUrl("http://www.baidu.com"); // you may change the target Url.
            //ScenarioAction.EndTime = DateTime.Now;
            ////service.SendAction(ScenarioAction);
            //ScenarioAction.Insert();

            ////ScenarioAction = new MonitorServer.Action() { Scenario = 2, BeginTime = DateTime.Now, Location = location };
            ////browser.GoToUrl("http://news.baidu.com/"); // you may change the target Url.
            ////ScenarioAction.EndTime = DateTime.Now;
            //////service.SendAction(ScenarioAction);
            ////ScenarioAction.Insert();



            browser.GoToUrl("https://intranet.my-dsm.com/org/dec/English/services/ia/Pages/default.aspx"); // you may change the target Url.
            System.Threading.Thread.Sleep(1000);

            // Scenario one
            var ScenarioAction = new MonitorServer.HtmlAction() { Scenario = 1, BeginTime = DateTime.Now, Location = location };
            ScenarioAction.Url = "https://intranet.my-dsm.com/org/cict/English/Pages/default.aspx?WT.svl=topnav";
            browser.GoToUrl(ScenarioAction.Url); // you may change the target Url.

            ScenarioAction.EndTime = DateTime.Now;
            ScenarioAction.Insert();

            System.Threading.Thread.Sleep(1000);

            // Scenario two
            ScenarioAction = new MonitorServer.HtmlAction() { Scenario = 2, BeginTime = DateTime.Now, Location = location };
            ScenarioAction.Url = "https://intranet.my-dsm.com/_layouts/globalsharing/UserProfiles/UserProfilesDetails.aspx";
            browser.GoToUrl(ScenarioAction.Url); // you may change the target Url.
            ScenarioAction.EndTime = DateTime.Now;
            ScenarioAction.Insert();
            System.Threading.Thread.Sleep(1000);

            // Scenario three
            ScenarioAction = new MonitorServer.HtmlAction() { Scenario = 3, BeginTime = DateTime.Now, Location = location };
            ScenarioAction.Url = "https://intranet.my-dsm.com/org/dec/English/services/ia/Documents/Forms/AllItems.aspx";
            browser.GoToUrl(ScenarioAction.Url); // you may change the target Url.
            ScenarioAction.EndTime = DateTime.Now;
            ScenarioAction.Insert();
            System.Threading.Thread.Sleep(2000);
            browser.TearDown();
        }


        private static void TestDsmStore()
        {
            var browser = new AutomationTestBase();
            browser.GoToUrl("http://dsmstore.intranet.dsm-group.com"); // you may change the target Url.

            AutomationOperation.InputTextControlByID(browser, "LoginUsername", userName);

            AutomationOperation.InputTextControlByID(browser, "LoginPassword", password);

            AutomationOperation.SelectByIDFilterWithText(browser, "DocbaseName", repository);

            //DocbaseName
            System.Threading.Thread.Sleep(1000);
            AutomationOperation.ControlClickByName(browser, "Login_loginButton_0");

            System.Threading.Thread.Sleep(3000);
            AutomationOperation.ClickByClassNameFilterWithText(browser, "buttonLink", "Logout");

            System.Threading.Thread.Sleep(1000);
            browser.TearDown();
        }
    }
}
